package com.sunmouse.toolkit.fragment.nav;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sunmouse.toollib.widget.FootNavLayout;
import com.sunmouse.toolkit.R;
import com.sunmouse.toolkit.fragment.BaseFragment;
import com.sunmouse.toolkit.fragment.chart.BrokenFragment;
import com.sunmouse.toolkit.fragment.chart.BubbleFragment;
import com.sunmouse.toolkit.fragment.chart.ColumnFragment;
import com.sunmouse.toolkit.fragment.chart.PieFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * A simple {@link Fragment} subclass.
 */
public class TabFragment extends BaseFragment {


    @BindView(R.id.fun_nav)
    FootNavLayout funNav;
    Unbinder unbinder;

    public TabFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_tab, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void init() {
        Fragment[] fragments = new Fragment[]{
                new BrokenFragment(),
                new ColumnFragment(),
                new PieFragment(),
                new BubbleFragment()
        };

        int[] icons = new int[]{
                R.drawable.tab_selector,
                R.drawable.tab_selector,
                R.drawable.tab_selector,
                R.drawable.tab_selector
        };

        String[] tabNames = getResources().getStringArray(R.array.tab_names);

        this.funNav.init(getActivity(), fragments, icons, tabNames, 0);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
